Skip to main content
POST
/
v1
/
knowledge
/
{kb_id}
/
documents
Add Knowledge Base Documents
curl --request POST \
  --url https://api.xpander.ai/v1/knowledge/{kb_id}/documents \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "document_urls": [
    "<string>"
  ]
}'
[
  {
    "kb_id": "<string>",
    "id": "<string>",
    "name": "<string>",
    "document_url": "<string>"
  }
]
Upload documents to a knowledge base by providing URLs. The documents will be downloaded, processed, and indexed for semantic search.

Path Parameters

kb_id
string
required
Unique identifier of the knowledge base (UUID format)

Request Body

document_urls
array
required
Array of document URLs to add to the knowledge baseSupported formats:
  • PDF documents
  • Microsoft Word (.docx, .doc)
  • Text files (.txt, .md)
  • Web pages (HTML)
  • CSV and Excel files
  • And more…
Example:
{
  "document_urls": [
    "https://example.com/document.pdf",
    "https://example.com/guide.docx",
    "https://example.com/data.csv"
  ]
}

Response

Returns an array of created document objects:
kb_id
string
Knowledge base ID
id
string
Unique identifier for the document (UUID)
name
string
Document name extracted from URL (nullable)
document_url
string
URL of the document
status
string
Initial processing status: pending

Example Request

curl -X POST -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document_urls": [
      "https://raw.githubusercontent.com/xpander-ai/xpander-sdk/main/README.md"
    ]
  }' \
  https://api.xpander.ai/v1/knowledge/4be18afd-ccbd-4092-8686-75e9df2a1bec/documents

Example Response

[
  {
    "kb_id": "4be18afd-ccbd-4092-8686-75e9df2a1bec",
    "id": null,
    "name": null,
    "document_url": "https://raw.githubusercontent.com/xpander-ai/xpander-sdk/main/README.md"
  }
]
Note: The id field is null initially. The document is queued for processing. After a few seconds, you can retrieve the document list to get the assigned ID.

Processing Flow

  1. Upload - Documents are queued for processing
  2. Download - System downloads documents from provided URLs
  3. Extract - Text content is extracted from documents
  4. Chunk - Content is split into searchable chunks
  5. Embed - Chunks are converted to vector embeddings
  6. Index - Embeddings are stored in the vector database
Processing typically takes 10-60 seconds per document depending on size.

Supported File Types

  • Documents: PDF, DOCX, DOC, TXT, MD, RTF
  • Spreadsheets: CSV, XLSX, XLS
  • Presentations: PPTX, PPT
  • Web: HTML, XML
  • Code: JSON, YAML, various programming languages

Notes

  • Documents must be publicly accessible via HTTP/HTTPS
  • Maximum file size: 50MB per document
  • Processing happens asynchronously - use [Get Document](/API reference/v1/knowledge/get-document) to check status
  • Duplicate URLs will create separate document entries

See Also

  • [List Documents](/API reference/v1/knowledge/list-documents) - View all documents in a knowledge base
  • [Get Document](/API reference/v1/knowledge/get-document) - Check document processing status
  • [Delete Document](/API reference/v1/knowledge/delete-document) - Remove documents
  • [Search Knowledge Base](/API reference/v1/knowledge/search-knowledge-base) - Search indexed documents

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

kb_id
string
required

Body

application/json

Request model for adding documents to a knowledge base.

document_urls
string[]
required

Documents URLs

Response

Successful Response

document_url
string
required

Document URL

kb_id
string | null

KB identifier

id
string | null

Document unique identifier

name
string | null

Document name